﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Taula = DeltaFlex.Negoci.ConsTaules.Concepte_Factura;
using System.Globalization;

namespace DeltaFlex.Negoci
{
    public class Concepte_Factura
    {
        #region Variables
        private int _idConcepte_Factura;
        private int _idFactura;
        private Albara _albara;
        #endregion

        #region Atributs
        public int IdConcepte_Factura
        {
            get { return _idConcepte_Factura; }
            set { _idConcepte_Factura = value; }
        }

        public int IdFactura
        {
            get { return _idFactura; }
            set { _idFactura = value; }
        }

        public Albara Albara
        {
            get { return _albara; }
            set { _albara = value; }
        }

        #region Bindings
        public string BindNumAlbara
        { 
            get { return _albara.IdAlbara.ToString(); }
        }

        public string BindNumPedido
        { 
            get { return _albara.OrdreTreball.PedidoClient; }
        }

        public string BindNumCodigo
        { 
            get { return string.Empty; }
        }

        public string BindDescripcio
        { 
            get { return _albara.OrdreTreball.IdTreball; } 
        }

        public string BindData
        { 
            get { return _albara.Data.ToString("dd-mm-aaaa"); } 
        }

        public string BindImportAlbara
        {
            get { return _albara.ImportTotal.ToString("C2", CultureInfo.CurrentCulture); }
        }
        #endregion
        #endregion

        #region Inserts
        public static void InsertarConcepte_Factura(int idFactura, int idAlbara)
        {
            try
            {
                Data.Concepte_Factura.InsertarConcepte_Factura(idFactura, idAlbara);
            }
            catch { throw; }
        }
        #endregion

        #region Updates
        #endregion

        #region Selects
        #endregion

        #region
        public static Concepte_Factura MapEntityFromDataReader(IDataReader record)
        {
            Concepte_Factura concepte_Factura = new Concepte_Factura();

            MemberAllocation.Allocate(record, Taula.COLUMNA_IDCONCEPTE_FACTURA, ref concepte_Factura._idConcepte_Factura);
            concepte_Factura._albara = Albara.MapEntityFromId(record);
            MemberAllocation.Allocate(record, Taula.COLUMNA_IDFACTURA, ref concepte_Factura._idFactura);

            return concepte_Factura;
        }
        #endregion

    }

}
